<template>
  <div class="view-container workOvertimeList">
    <header class="view-header">
      <div class="header-container">
        <div class="header-title">
          <i class="el-icon-s-grid"></i>
          <span>外出审批</span>
        </div>
        <div class="header-form">
          <!--更多-->
<!--          <div class="header-form-item">
            <el-dropdown @command="handleCommand">
              <el-button type="default" :loading="delLoading">
                更多<i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>
              </el-button>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item icon="el-icon-refresh-right" class="color-refresh-item" command="refresh">刷新
                </el-dropdown-item>
                <el-dropdown-item icon="el-icon-edit" class="color-edit-item" command="edit">编辑</el-dropdown-item>
                <el-dropdown-item icon="el-icon-delete" class="color-del-item" command="del">{{isBatchesDel}}
                </el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>-->
          <!--搜索-->
<!--          <div class="header-form-item">
            <el-button type="primary" icon="el-icon-search" @click="fetchData">查询</el-button>
          </div>
          <div class="header-form-item">
            <el-button type="success" icon="el-icon-s-check" @click="doApproval">审批</el-button>
          </div>-->
        </div>
      </div>
    </header>

    <section>
      <el-table
        ref="table"
        :data="tableData"
        border
        stripe
        @selection-change="handleSelectionChange"
        @row-click="handleRowClick"
      >
        <el-table-column type="selection" align="center"/>
        <el-table-column prop="waiChuRenName" label="申请人" align="center" width="100"/>
        <el-table-column prop="waiChuShiYou" label="事由" align="left" >
          <template slot-scope="s">
            <el-link @click="showDetail(s.row.waiChuId)">{{s.row.waiChuShiYou}}</el-link>
          </template>
        </el-table-column>
        <el-table-column sortable :formatter="startTimeFmt" prop="startTime" label="开始时间" align="center" width="150"/>
        <el-table-column sortable :formatter="endTimeFmt" prop="endTime" label="结束时间" align="center" width="150"/>
        <el-table-column prop="isCar" label="是否带车" align="center" width="100"/>
        <el-table-column label="操作" align="center" width="100">
          <template slot-scope="s">
            <el-link @click="showDetail(s.row.waiChuId)">审批</el-link>
            <!--<el-tag :type="switchType(s.row.stateName)">{{s.row.stateName}}</el-tag>-->
          </template>
        </el-table-column>
      </el-table>
    </section>

    <footer>
      <el-pagination
        :page-sizes="[10, 20, 50, 100]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total"
        :page-size="page.size"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </footer>

  </div>
</template>

<script>
  import listMixin from '@/mixin/listMixin'
  import waiChuAPI from '@/api/waiChu/waiChu'
  export default {
    name: 'JiaBanApprovalList',
    mixins: [listMixin],
    data() {
      return {
      }
    },
    created() {
    },
    computed: {
    },
    methods: {
      showDetail(id){
        this.$router.push('/work-waichu/approval-detail/'+id+'/'+true)
      },
      fetchData() {
        waiChuAPI.auditList(this.page).then(res => {
          console.log('waiChuAPI.auditList',res)
          this.tableData = res.records
          this.page.total = res.total
        })
      },
      startTimeFmt(row){
        return this._util.format(row.startTime)
      },
      endTimeFmt(row){
        return this._util.format(row.endTime)
      }
    }
  }
</script>

<style lang="scss">
</style>

